/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cz.muni.fi.j002.requirementengineeringmuni.swing;

import cz.muni.fi.j002.requirementengineeringmuni.Game;
import cz.muni.fi.j002.requirementengineeringmuni.entities.Card;
import cz.muni.fi.j002.requirementengineeringmuni.entities.Move;
import cz.muni.fi.j002.requirementengineeringmuni.impl.DeckImpl;
import java.util.ArrayList;
import java.util.List;
import javax.swing.table.AbstractTableModel;

/**
 *
 * @author stefan
 */
public class CardsJTableModel extends AbstractTableModel {
    
    public static final int NUMBER_OF_ROWS = 13;

    private Game game;

    public CardsJTableModel setGame(Game game) {
        this.game = game;
        return this;
    }
    
    @Override
    public int getRowCount() {
        return Math.min(NUMBER_OF_ROWS, game.getPlayedMoves().size());
    }

    @Override
    public int getColumnCount() {
        return 4;
    }

    @Override
    public Object getValueAt(int rowIndex, int columnIndex) {
        int moveIndex = NUMBER_OF_ROWS * columnIndex + rowIndex;
        if(moveIndex >= game.getPlayedMoves().size()) return null;
        Card card = game.getPlayedMoves().get(moveIndex).getCard();
        return card.getValue().getValue() + card.getSign().getCode();
    }
    
    @Override
    public String getColumnName(int columnIndex) {
        switch (columnIndex) {
            case 0:
                return "1st quarter";
            case 1:
                return "2nd quarter";
            case 2:
                return "3rd quarter";
            case 3:
                return "4th quarter";
            default:
                throw new IllegalArgumentException("columnIndex");
        }
    }
}
